package org.zephyr.struct.bridge.ex;

import javax.swing.*;
import java.awt.*;
import java.util.Objects;

public class Test {
    public static void main(String[] args) {
        /*Color red=new Red();
        Color yellow=new Yellow();

        Bag wallet=new Wallet();
        wallet.setColor(red);

        System.out.println(wallet.getName());*/

        Color color;
        Bag bag;
        color= (Color) ReadXML.getObject("color");
        bag= (Bag) ReadXML.getObject("bag");

        bag.setColor(color);
        String name=bag.getName();
        show(name);

    }

    public static void show(String name){
        JFrame frame=new JFrame("桥接模式测试");
        Container contentPane=frame.getContentPane();
        JPanel panel=new JPanel();
        JLabel label=new JLabel(new ImageIcon("src/main/java/org/zephyr/struct/bridge/ex/"+name+".png"));
        panel.setLayout(new GridLayout(1,1));
        panel.setBorder(BorderFactory.createTitledBorder("女士皮包"));
        panel.add(label);
        contentPane.add(panel,BorderLayout.CENTER);
        frame.pack();
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
